package app.fugema.shop.main.goods.adapter;

import android.view.View;

import com.base.common.utils.UIUtils;
import com.base.common.view.adapter.ada.BaseRVAdapter;
import com.base.common.view.adapter.connector.BaseItemMultiType;
import com.base.common.view.adapter.connector.BaseItemTypeInterface;
import com.base.common.view.adapter.connector.BaseViewHolder;
import com.base.common.view.widget.imageView.ImageLoaderUtils;
import app.fugema.shop.R;
import app.fugema.shop.databinding.ItemVshopInfoHeaderBinding;
import app.fugema.shop.main.goods.model.VShopResult;
import app.fugema.shop.main.goods.view.ShopCateActivity;
import app.fugema.shop.main.goods.view.ShopInfoActivity;

public class ShopInfoBaseItemMultiType extends BaseItemMultiType<VShopResult.VShopBean, ItemVshopInfoHeaderBinding>
{
    @Override
    public int getLayoutId()
    {
        return R.layout.item_vshop_info_header;
    }

    @Override
    public int getItemViewType() {
        return BaseItemTypeInterface.TYPE_HEAD_TWO;
    }

    @Override
    public boolean isFullSpanType() {
        return true;
    }

    @Override
    public void onCreateViewHolder(ItemVshopInfoHeaderBinding binding, BaseViewHolder viewHolder)
    {
        super.onCreateViewHolder(binding, viewHolder);
    }

    @Override
    public void onBindViewHolder(ItemVshopInfoHeaderBinding binding, int position, VShopResult.VShopBean bean)
    {
        super.onBindViewHolder(binding, position, bean);
        if( UIUtils.isNotEmpty( bean.getLogo() ) )
        {
            ImageLoaderUtils.loadImage( binding.ivShopLogo , bean.getLogo() );
        }
        binding.tvShopName.setText( bean.getName() );
        binding.ivLikeBtn.setImageResource( bean.isFavorite()?R.mipmap.ic_like:R.mipmap.ic_like_white );
    }


    @Override
    public void onItemClick(View view, BaseRVAdapter adapter, int onclickType, int position, VShopResult.VShopBean bean) {
        super.onItemClick(view, adapter, onclickType, position, bean);
        int shopId = bean.getShopId();
        switch (view.getId())
        {
            case R.id.tv_shop_all_goods_tag:
                 UIUtils.showToastSafes("全部商品");
                 break;
            case R.id.tv_shop_info_tag:
                ShopInfoActivity.start(view.getContext(),bean.getShopId());
                break;
            case R.id.tv_shop_cate_tag:

                ShopCateActivity.start(view.getContext(),bean.getShopId());
                break;
        }
    }


}
